import { Routes, RouterModule, PreloadAllModules } from "@angular/router";
import { LoginComponent } from "./login/login.component";

import { NgModule } from "@angular/core";
import { MyProloadingStrategy } from "./common/my-proloading-strategy";
import { MyAuthGuard } from "./common/my-auth-guard";

export const routes : Routes = [
    {
        path : '',
        redirectTo : "/login",
        pathMatch: "full"
    },
    {
        path: "login",
        component: LoginComponent
    },
    {
        path: 'home',
        data: { preload : true }, 
        canActivate:[MyAuthGuard],
        canLoad: [MyAuthGuard],
		loadChildren: './home/home.module#HomeModule'
    },
    {
        path: "**",
        redirectTo: "login",
        pathMatch: "full"
    }
    
    
]

@NgModule({
    // imports: [RouterModule.forRoot(routes, {preloadingStrategy: PreloadAllModules})], // 懒加载所有模块
    imports: [RouterModule.forRoot(routes, {preloadingStrategy: MyProloadingStrategy})], // 懒加载指定模块
    // imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule]
  })
export class AppRoutes { }
